package com.bstek.urule.console.servlet.scriptdecisiontable;

import com.bstek.urule.Utils;
import com.bstek.urule.console.servlet.base.BaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * <p>
 * 脚本决策
 * </p>
 *
 * @author zhouchaoliang
 * @since 2021/12/9
 */
@Controller
public class ScriptDecisiontableEditorController extends BaseController {

    /**
     * 脚本决策
     *
     * @param req
     * @param resp
     * @return
     */
    @GetMapping("/urule/scriptdecisiontableeditor")
    public ModelAndView scriptdecisiontable(HttpServletRequest req, HttpServletResponse resp) {
        ModelAndView mv = new ModelAndView("/scriptdecisiontable-editor");
        mv.addObject("contextPath", req.getContextPath());
        String file = req.getParameter("file");
        file = Utils.decodeURL(file);
        String project = buildProjectNameFromFile(file);
        if (project != null) {
            mv.addObject("project", project);
        }
        return mv;
    }
}
